
const tokens = {
  admin: {
    token: 'admin-token'
  },
  editor: {
    token: 'editor-token'
  }
}

const users = {
  'admin-token': {
    account:'admin',
    realName:'王远霞',
    nickName:'可可爱爱',
    roles: ['admin'],
    sex:'女',
    mobile:'18989225275',
    tel:'',
    email:'@email()',
    address:'四川省成都市郫都区安靖镇',
    wx:'8008896125',
    roleNames: ['admin'],
    accountStatus:'在职',
    organCode:'112352',
    position:'前端工程师',
    head: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  },
  'editor-token': {
    roleNames: ['editor'],
    introduction: 'I am an editor',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Normal Editor'
  }
}

export default [
  // user login
  {
    url: '/user/login',
    type: 'post',
    response: config => {
      const { account } = config.body
      const token = tokens[account]
      return {
        code: 20000,
        data: token
      }
    }
  },

  // get user info
  {
    url: '/user/getUser\.*',
    type: 'get',
    response: config => {
      const { token } = config.query
      const info = users[token]
      // mock error
      if (!info) {
        return {
          code: 50008,
          msg: 'Login failed, unable to get user details.'
        }
      }

      return {
        code: 20000,
        data: info
      }
    }
  },

  // user logout
  {
    url: '/user/logout',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },
  
  // 修改密码
  {
    url: '/user/modifyUserPassword',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },
  
  // 上传头像
  {
    url: '/user/uploadAvatar',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
  
]
